

use RD_common;
go

select * from dbo.Star_UOMConversionFactors

where ConversionFactor <>0 and ConvFactorSecondaryToPrimary<>0 
and  ItemNumber in (48157)


in (35533,
35534,
35535,
590,
48157,
35607,
35609,
35614,
35616,
43318,
36079,
45678,
46579,
36119,
36121,
45141,
45139,
68899,
68707,
65033,
65037,
65035,
65040)

-- find inverse data

select 
	SOURCE,
	SourceID,
	BusinessUnitCode,
	ItemNumber,
	RelatedUnitOfMeasure as UnitOfMeasure,
	UnitOfMeasure as RelatedUnitOfMeasure,
	UnitOfMeasureStructure,
	--1.00/ConversionFactor as 
	ConversionFactor,
	--1.00/ConvFactorSecondaryToPrimary as 
	ConvFactorSecondaryToPrimary,
	UserID,
	ProgramID,
	WorkStationID,
	DateUpdated,
	TimeOfDay,
	ExcludefromPO,
	ExcludefromSO,
	CodePurchasePriceCode,
	CodeSalesPriceCode,
	InsertIndicator,
	InsertDate,
	ChangeIndicator,
	ChangeDate,
	DeleteIndicator,
	DeleteDate,
	PurgeDate 
from 
	dbo.Star_UOMConversionFactors 
where 
	ConversionFactor <>0 and 
	ConvFactorSecondaryToPrimary<>0 and
	ItemNumber not in  (36117,37415,38424,38425, 38426,43135,44426,45162,59375,68628)
-- Excetption list grown, 03/22/2012 




insert into dbo.Star_UOMConversionFactors

select 
	SOURCE,
	SourceID,
	BusinessUnitCode,
	ItemNumber,
	RelatedUnitOfMeasure as UnitOfMeasure,
	UnitOfMeasure as RelatedUnitOfMeasure,
	UnitOfMeasureStructure,
	1.00/ConversionFactor as ConversionFactor,
	1.00/ConvFactorSecondaryToPrimary as ConvFactorSecondaryToPrimary,
	UserID,
	ProgramID,
	WorkStationID,
	DateUpdated,
	TimeOfDay,
	ExcludefromPO,
	ExcludefromSO,
	CodePurchasePriceCode,
	CodeSalesPriceCode,
	InsertIndicator,
	InsertDate,
	ChangeIndicator,
	ChangeDate,
	DeleteIndicator,
	DeleteDate,
	PurgeDate 
from 
	dbo.Star_UOMConversionFactors 
where 
	ConversionFactor <>0 and 
	ConvFactorSecondaryToPrimary<>0 and ItemNumber not in  (36117,37415,38424,38425, 38426,43135,44426,45162,59375,68628, 37318)
/**12/14/12 ** Luong Request for Stephani **/
and ItemNumber in (35533,
35534,
35535,
590,
48157,
35607,
35609,
35614,
35616,
43318,
36079,
45678,
46579,
36119,
36121,
45141,
45139,
68899,
68707,
65033,
65037,
65035,
65040)
-- end of Luong Request 12/14/12

INSERT INTO [RD_COMMON].[dbo].[Star_Item]
           ([ItemNumberID]
           ,[SourceID]
           ,[Source]
           ,[ItemNumber]
           ,[ItemNumber02]
           ,[ItemNumber03]
           ,[Description01]
           ,[Description02]
           ,[SalesCategory01Code]
           ,[SalesCategory01]
           ,[SalesCategory02Code]
           ,[SalesCategory02]
           ,[SalesCategory03Code]
           ,[SalesCategory03]
           ,[SalesCategory04Code]
           ,[SalesCategory04]
           ,[SalesCategory05Code]
           ,[SalesCategory05]
           ,[SalesCategory06Code]
           ,[SalesCategory06]
           ,[SalesCategory07Code]
           ,[SalesCategory07]
           ,[SalesCategory08Code]
           ,[SalesCategory08]
           ,[SalesCategory09Code]
           ,[SalesCategory09]
           ,[SalesCategory10Code]
           ,[SalesCategory10]
           ,[PurchasingCategory01Code]
           ,[PurchasingCategory01]
           ,[PurchasingCategory02Code]
           ,[PurchasingCategory02]
           ,[PurchasingCategory03Code]
           ,[PurchasingCategory03]
           ,[PurchasingCategory04Code]
           ,[PurchasingCategory04]
           ,[PurchasingCategory05Code]
           ,[PurchasingCategory05]
           ,[PurchasingCategory06Code]
           ,[PurchasingCategory06]
           ,[PurchasingCategory07Code]
           ,[PurchasingCategory07]
           ,[PurchasingCategory08Code]
           ,[PurchasingCategory08]
           ,[PurchasingCategory09Code]
           ,[PurchasingCategory09]
           ,[PurchasingCategory10Code]
           ,[PurchasingCategory10]
           ,[ProductGroupCode]
           ,[ProductGroup]
           ,[ItemPriceGroupCode]
           ,[ItemPriceGroup]
           ,[StockingTypeCode]
           ,[StockingType]
           ,[InsertIndicator]
           ,[InsertDate]
           ,[ChangeIndicator]
           ,[ChangeDate]
           ,[DeleteIndicator]
           ,[DeleteDate]
           ,[PurgeDate])
     VALUES
           (1
           ,1
           , 'FARMER_CUSTOM'
           ,0
           ,'Advanced Pricing Adj Line'
           , 'Advanced Pricing Adj Line'
           , 'Advanced Pricing Adj Line'
           ,''
           ,''
           ,''
           ,''
           ,''
           ,''
           , ''
           , ''
           , ''
           , ''
           , ''
           , ''
           , ''
           , ''
           , ''
           , ''
           , ''
           , ''
           , ''
           , ''
           , ''
           , ''
           , ''
           , ''
           , ''
           , ''
           , ''
           , ''
           , ''
           , ''
           , ''
           , ''
           , ''
           , ''
           , ''
           , ''
           , ''
           , ''
           , ''
           , ''
           , ''
           , ''
           , ''
           , ''
           , ''
           , ''
           , ''
           ,0
           ,0
           ,0
           ,0
           ,0
           ,0
           ,0)

/**


select 
SOURCE,
SourceID,BusinessUnitCode,
ItemNumber,
RelatedUnitOfMeasure as UnitOfMeasure,
UnitOfMeasure as RelatedUnitOfMeasure,
UnitOfMeasureStructure,
1.00/ConversionFactor as ConversionFactor,
1.00/ConvFactorSecondaryToPrimary as ConvFactorSecondaryToPrimary,
UserID,
ProgramID,
WorkStationID,
DateUpdated,
TimeOfDay,
ExcludefromPO,
ExcludefromSO,
CodePurchasePriceCode,
CodeSalesPriceCode,
InsertIndicator,
InsertDate,
ChangeIndicator,
ChangeDate,
DeleteIndicator,
DeleteDate,
PurgeDate 
from dbo.Star_UOMConversionFactors 
where ConversionFactor <>0 and ConvFactorSecondaryToPrimary<>0

**/